<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{common/common::head}"></head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>
                    <a style="color: rgb(30 159 255)" class="xss-reflect">跨站脚本攻击 - 反射型XSS</a>
                    </legend>
                    <blockquote class="layui-elem-quote layui-quote-nm"
                                style="font-size: 15px;background-color: #a7deefab;box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075) !important">
                        <pre>  XSS(跨站脚本攻击)利用浏览器对服务器内容的信任，攻击者通过在网页中注入恶意脚本，使这些脚本在用户的浏览器上执行，从而实现攻击。常见的XSS攻击危害包括窃取用户会话信息、篡改网页内容、将用户重定向到恶意网站，以及执行恶意操作(如点击劫持和钓鱼攻击)
  反射型XSS：攻击者通过在URL参数中注入恶意脚本，使服务器将该脚本直接反射回用户浏览器并执行。该攻击一般不涉及数据库，而是通过服务器处理用户请求时立即返回恶意内容</pre>
                    </blockquote>
                </fieldset>
            </div>

            <div class="layui-col-md12" style="margin-top: 10px">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md6">
                        <h1><span class="iconfont icon-bug"> 漏洞场景：GET型与POST型</span></h1>
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">GET型</li>
                                <li>POST型</li>
                                <li>String</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <blockquote class="layui-elem-quote main_btn">
                                        <form class="layui-form" style="display: flex; justify-content: space-between;">
                                            <input type="text" name="payload" style="width: 300px;" required
                                                   lay-verify="required" value="<script>alert(/xss/)</script>" autocomplete="off"
                                                   class="layui-input" id="vul1-reflect-raw-get-input">
                                            <div style="display: flex; align-items: center;">
                                                <select class="layui-form-select" lay-filter="vul1-reflect-raw-get">
                                                    <option value="">示例Payload</option>
                                                    <option value="123&lt;u&gt;A&lt;/u&gt;123">探测漏洞标签</option>
                                                    <option value="重定向恶意网站-SEO引流&lt;a href=javascript:window.location.href=&#x27;http://bilibili.com&#x27;&gt;Click Me&lt;/a&gt;">
                                                        恶意流量劫持
                                                    </option>
                                                    <option value="&lt;a href=&#x27;/other/cookie.txt&#x27; target=&#x27;_blank&#x27;&gt;点击查看&lt;/a&gt;&lt;script src=&#x27;/static/js/hackcookie.js&#x27;&gt;&lt;/script&gt;">
                                                        窃取用户信息
                                                    </option>
                                                    <option value="修改背景颜色为红色&lt;img src onerror=javascript:document.getElementsByClassName(&#x27;layuimini-container&#x27;)[0].style.backgroundColor=&#x27;red&#x27;&gt;">
                                                        篡改网页内容
                                                    </option>
                                                </select>
                                                <button class="layui-btn layui-btn-normal" style="width: 100px; margin-left: 10px;" lay-filter="vul1-reflect-raw-get" lay-submit="">
                                                    <span class="iconfont icon-zhihang">Run</span>
                                                </button>
                                            </div>
                                        </form>
                                    </blockquote>
                                </div>

                                <div class="layui-tab-item">
                                    <blockquote class="layui-elem-quote main_btn">
                                        <form class="layui-form" style="display: flex; justify-content: space-between;">
                                            <input type="text" name="payload" style="width: 300px;" required
                                                   lay-verify="required" value="<script>alert(/xss/)</script>" autocomplete="off"
                                                   class="layui-input">
                                            <button class="layui-btn layui-btn-normal" style="width: 100px; margin-left: 10px;" lay-filter="vul1-reflect-raw-post" lay-submit="">
                                                <span class="iconfont icon-zhihang">Run</span>
                                            </button>
                                        </form>
                                    </blockquote>
                                </div>

                                <div class="layui-tab-item">
                                    <blockquote class="layui-elem-quote main_btn">
                                        <p>Controller接口返回的数据是String类型</p>
                                        <a target="_blank" href="/xss/reflect/vul2?payload=%3Cscript%3Ealert(/xss/)%3C/script%3E">
                                            <button class="layui-btn layui-btn-normal" style="width: 100px; margin-left: 10px;">
                                                <span class="iconfont icon-zhihang">Run</span>
                                            </button>
                                        </a>
                                    </blockquote>
                                </div>

                                <div class="layui-col-md12">
                                    <div class="layui-card">
                                        <div class="layui-card-header"><i class="fa fa-bullhorn icon-tip"></i>tips</div>
                                        <div class="layui-card-body layui-text layadmin-text">
                                            <pre style="color: #28333e;font-size: 12px;">Java后端返回数据有以下几种形式：
    响应String字符串：返回一个字符串作为响应，一般用于返回纯文本数据
    响应JSON数据：返回一个JSON对象作为响应，适用于前后端分离或移动端接口
    响应XML数据：返回一个XML对象作为响应，适用于与其他系统进行数据交互
    响应二进制数据：返回一个字节数组或文件流作为响应，适用于文件下载或图片等二进制数据的返回
    响应数据流：返回一个数据流对象作为响应，适用于大文件或大数据量的返回
    响应视图模板：通过模板引擎将数据填充到模板中，生成最终的HTML页面
    响应重定向：将请求重定向到另一个URL，适用于页面跳转或处理不同的请求
    响应错误码：返回一个错误码和错误信息作为响应，用于指示请求出现错误或异常</pre>
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-col-md12">
                                    <div class="layui-card">
                                        <div class="layui-card-header"><i class="fa fa-warning icon-output"></i>测试结果</div>
                                        <div class="layui-card-body layui-text layadmin-text">
                                            <pre id="vul1-reflect-raw-result" style="color: red;font-size: 15px;"></pre>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md6">
                        <h1><span class="iconfont icon-code"> 缺陷代码</span></h1>
                        <div class="m-auto div-shadow shadow p-3 mb-5 bg-white rounded">
                            <div class="code-editor" id="vul1ReflectRaw"></div>
                        </div>
                    </div>

                </div>
            </div>

            <div class="layui-col-md12" style="margin-top: 10px">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md6">
                        <h1><span class="iconfont icon-bug"> 漏洞场景：Content-Type问题</span></h1>
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">text/plain</li>
                                <li>text/html</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <blockquote class="layui-elem-quote main_btn">
                                        <p>text/plain：浏览器在获取到这种文件时并不会对其进行处理，将文件设置为纯文本的形式</p>
                                        <a target="_blank" href="/xss/reflect/vul3?type=plain&payload=123<script>alert(/xss/)</script>123">
                                            <button class="layui-btn layui-btn-normal" style="width: 100px; margin-left: 10px;">
                                                <span class="iconfont icon-zhihang">Run</span>
                                            </button>
                                        </a>
                                    </blockquote>
                                </div>

                                <div class="layui-tab-item">
                                    <blockquote class="layui-elem-quote main_btn">
                                        <p>text/html：浏览器在获取到这种文件时会自动调用html的解析器对文件进行相应的处理</p>
                                        <a target="_blank" href="/xss/reflect/vul3?type=html&payload=123<script>alert(/xss/)</script>123">
                                            <button class="layui-btn layui-btn-normal" style="width: 100px; margin-left: 10px;">
                                                <span class="iconfont icon-zhihang">Run</span>
                                            </button>
                                        </a>
                                    </blockquote>
                                </div>

                                <div class="layui-col-md12">
                                    <div class="layui-card">
                                        <div class="layui-card-header"><i class="fa fa-bullhorn icon-tip"></i>tips</div>
                                        <div class="layui-card-body layui-text layadmin-text">
                                            <pre style="color: #28333e;font-size: 15px;">
Content-Type属性指定响应的HTTP内容类型。如果未指定ContentType，默认为text/html
                                            </pre>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md6">
                        <h1><span class="iconfont icon-code"> 缺陷代码</span></h1>
                        <div class="m-auto div-shadow shadow p-3 mb-5 bg-white rounded">
                            <div class="code-editor" id="vul2ReflectContentType"></div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<script th:replace="~{common/common::script}"></script>
<script type="text/javascript">
    layui.use(['layer', 'miniTab', 'common', 'form'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            miniTab = layui.miniTab,
            common = layui.common,
            form = layui.form;
        miniTab.listen();
        layer.msg("跨站脚本-反射型");

        common.formListenFun("vul1-reflect-raw-get", "", "/xss/reflect/vul1", "vul1-reflect-raw-result", "get");
        common.formListenFun("vul1-reflect-raw-post", "", "/xss/reflect/vul1", "vul1-reflect-raw-result", "post");
        common.selectListenFun("vul1-reflect-raw-get", "vul1-reflect-raw-get-input");

        var cmConfig = {
            lineNumbers: true,
            lineWrapping: false,
            indentUnit: 4,
            indentWithTabs: true,
            theme: 'juejin',
            styleActiveLine: {nonEmpty: true},
            fontSize: "18px",
            mode: "text/x-java"
        };

        CodeMirror(document.getElementById("vul1ReflectRaw"), Object.assign({}, cmConfig, {
            value: vul1ReflectRaw
        }));
        CodeMirror(document.getElementById("vul2ReflectContentType"), Object.assign({}, cmConfig, {
            value: vul2ReflectContentType
        }));

        $('.xss-reflect').hover(function () {
            $(this).css('cursor', 'pointer');
            layer.tips('攻击流程图', this, {
                tips: [1, '#0051ff'],
                time: 2000
            });
        });

        $('.xss-reflect').on('click', function () {
            layer.open({
                type: 1,
                title: false,
                closeBtn: 1,
                area: ['837px', '649.8px'], // 宽高缩小为0.9倍
                shadeClose: true,
                content: '<div style="text-align: center;"><img src="/static/images/vul/xss/reflect.png" style="width: 100%; height: 50%;"></div>'
            });
        });
    });

</script>
</body>
</html>
